# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
import shutil

class Recipe(custom.GStreamer):
    name = 'gstreamer-1.0'
    config_sh = 'sh ./autogen.sh --noconfigure && ./configure'
    configure_options = "--enable-static --program-prefix= --disable-examples "
    remotes = {'origin': 'git://anongit.freedesktop.org/gstreamer/gstreamer'}
    commit = '087eca882733cf20e007171a161db964de254293'
    deps = ['glib', 'gtk-doc-lite']

    files_bins = ['gst-inspect-1.0',
                  'gst-typefind-1.0',
                  'gst-launch-1.0']

    files_libs = ['libgstbase-1.0', 'libgstcontroller-1.0',
                  'libgstnet-1.0', 'libgstreamer-1.0']

    platform_files_libs = {
        Platform.LINUX: ['libgstcheck-1.0'],
        Platform.ANDROID: ['libgstcheck-1.0'],
        Platform.DARWIN: ['libgstcheck-1.0'],
    }

    files_plugins_core = ['lib/gstreamer-1.0/libgstcoreelements%(mext)s']
    files_plugins_core_devel = [
        'lib/gstreamer-1.0/libgstcoreelements.a', 'lib/gstreamer-1.0/libgstcoreelements.la',
    ]

    files_misc = ['libexec/gstreamer-1.0/gst-plugin-scanner%(bext)s']

    platform_files_misc = {
        Platform.LINUX: ['libexec/gstreamer-1.0/gst-ptp-helper%(bext)s'],
        Platform.DARWIN: ['libexec/gstreamer-1.0/gst-ptp-helper%(bext)s'],
    }

    files_devel = [
            'include/gstreamer-1.0/gst/*.h',
            'include/gstreamer-1.0/gst/base',
            'include/gstreamer-1.0/gst/controller',
            'include/gstreamer-1.0/gst/net',
            'lib/pkgconfig/gstreamer-1.0.pc',
            'lib/pkgconfig/gstreamer-base-1.0.pc',
            'lib/pkgconfig/gstreamer-controller-1.0.pc',
            'lib/pkgconfig/gstreamer-net-1.0.pc',
    ]

    platform_files_devel = {
        Platform.LINUX: ['include/gstreamer-1.0/gst/check', 'lib/pkgconfig/gstreamer-check-1.0.pc', 'share/aclocal/gst-element-check-1.0.m4'],
        Platform.ANDROID: ['include/gstreamer-1.0/gst/check', 'lib/pkgconfig/gstreamer-check-1.0.pc', 'share/aclocal/gst-element-check-1.0.m4'],
        Platform.DARWIN: ['include/gstreamer-1.0/gst/check', 'lib/pkgconfig/gstreamer-check-1.0.pc', 'share/aclocal/gst-element-check-1.0.m4'],
    }

    files_lang = ['gstreamer-1.0']

    files_typelibs = [
        'Gst-1.0',
        'GstBase-1.0',
        'GstCheck-1.0',
        'GstController-1.0',
        'GstNet-1.0'
        ]


    def prepare(self):
        self.append_env['CFLAGS'] = " -Wno-error "
        self.append_env['CXXFLAGS'] = " -Wno-error "
        self.append_env['CPPFLAGS'] = " -Wno-error "
        if self.config.target_platform != Platform.LINUX:
            self.configure_options += ' --disable-gtk-doc --disable-docbook'

        if self.config.target_platform == Platform.IOS:
            # iOS only supports static builds so plugins must be linked
            # and registered statically.
            self.configure_options += ' --disable-registry '

        if self.config.variants.nodebug:
            self.append_env['CFLAGS'] += ' -DGST_LEVEL_MAX=GST_LEVEL_FIXME'

    def post_install(self):
        pass
